package summary;

import java.util.PriorityQueue;

/**
 * @Author: 海琳琦
 * @Date: 2022/6/9 9:44
 * https://leetcode.cn/problems/maximum-product-of-two-elements-in-an-array/
 */
public class Title1464 {

    public int maxProduct(int[] nums) {
        //取得前两个最大值
        PriorityQueue<Integer> queue = new PriorityQueue<>((a, b) -> (b.compareTo(a)));
        for (int i = 0; i < nums.length; i++) {
            queue.offer(nums[i]);
        }
        return (queue.poll() - 1) * (queue.poll() - 1);
    }

    public static void main(String[] args) {

    }
}
